﻿using System.Collections.Generic;

namespace SAS.Core
{
    public class SearchParameters
    {
        #region public variables

        /// <summary>
        /// 
        /// </summary>
        public List<SearchParameter> Items { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string Andor { get; set; }

        #endregion

        #region constructor

        /// <summary>
        /// 
        /// </summary>
        public SearchParameters()
        {
            Items = new List<SearchParameter>();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="paramstring"></param>
        public SearchParameters(string paramstring)
        {
            string[] outer = paramstring.Split(':');
            string[] inner = outer[1].Split(';');
            Andor = outer[0];
            Items = new List<SearchParameter>();
            foreach (string t in inner)
            {
                string[] param = t.Split(',');
                SearchParameter item = new SearchParameter
                                           {
                                               Column = param[0],
                                               Datatype = param[1],
                                               Operator = param[2],
                                               Value0 = param[3],
                                               Value1 = param[4],
                                               Value2 = param[5],
                                               Value3 = param[6]
                                           };
                Items.Add(item);
            }
        }

        #endregion
    }
}